<template>
  <div>
    <div class="InputBox">
      <el-form :model="PublicForm" label-width="20px" class="Form" >
        <!-- -----------INPUT -->
        <el-form-item >
          <template>
            <div class="text">{{ this.$route.meta.BtnText && this.$route.meta.BtnText.number }}</div>
            <el-input v-model="PublicForm.innerCooder" placeholder="请输入" style="width: 228px;" />
          </template>
        </el-form-item>
        <!-- <el-form-item>
          <template>
            <div class="text">{{ this.$route.meta.BtnText && this.$route.meta.BtnText.number }}</div>
            <el-select v-model="PublicForm.state" placeholder="请选择" style="width: 228px;">
              <el-option v-for="(item, index) in data" :key="index" :label="item.text" :value="item.core" />
            </el-select>
          </template>
        </el-form-item> -->
        <!-- -------------------INPUT -->
        <el-form-item v-if="!Select">
          <template>
            <div class="text">{{ this.$route.meta.BtnText && this.$route.meta.BtnText.name }}</div>
            <el-input v-model="PublicForm.name" placeholder="请输入" style="width: 228px;" />
          </template>
        </el-form-item>
        <el-form-item v-else>
          <template>
            <div class="text">{{ this.$route.meta.BtnText && this.$route.meta.BtnText.name }}</div>
            <el-select v-model="PublicForm.name" placeholder="请选择" style="width: 228px;">
              <el-option v-for="(item, index) in data" :key="index" :label="item.text" :value="item.core" />
            </el-select>
          </template>
        </el-form-item>
        <!-- ---------------------INPUT -->
        <el-form-item>
          <template v-if="!Check">
            <div class="text">{{ this.$route.meta.BtnText && this.$route.meta.BtnText.state }}</div>
            <el-select v-model="PublicForm.state" placeholder="请选择" style="width: 228px;">
              <el-option v-for="(item, index) in data" :key="index" :label="item.text" :value="item.core" />
            </el-select>
          </template>
        </el-form-item>
        <slot />
      </el-form>
      <div class="FormBtn">
        <el-button type="warning" @click="$emit('SearchBtn', PublicForm)">搜索</el-button>
        <el-button type="warning" style="background-color: #f8f5f5;" @click.native="ResetFields">重置</el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      PublicForm: {
        innerCooder: '',
        name: '',
        state: ''
      },
      data: [
        {
          text: '全部',
          core: 2
        },
        {
          text: '启用',
          core: 1
        },
        {
          text: '停用',
          core: 0
        }
      ],
      // 第三搜索框是否存在
      check: [
        '货品管理', '货品类型管理', '货主管理', '承运商管理'
      ],
      // input切换为select框
      select: ['盘点单']
    }
  },
  created() {
  },
  methods: {
    ResetFields() {
      this.PublicForm = {
        innerCooder: '',
        name: '',
        state: ''
      }
    }
  },
  computed: {
    // 第三个搜索框是否显示
    Check() {
      return this.check.includes(this.$route.meta.title)
    },
    Select() {
      return this.select.includes(this.$route.meta.title)
    }
  }
}
</script>

<style lang="scss" scoped>
.InputBox{
  display: flex;
  justify-content: space-between;
  background-color: pink;
  min-height: 100px;
  width: 92%;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 0 6px 0 rgb(144 142 142 / 17%);
  padding: 10px;
  margin:20px 0px 20px 50px;
}
.Form{
  display: flex;
  // margin-right:50px;
  margin-top:10px;
  flex-wrap: wrap;
}
.FormBtn{
  margin-top:50px;
  width:20%;
  .el-button{
    height: 40px;
    width: 80px;
    border-radius: 20px;
    border: 0;
    font-size: 14px;
    font-family: PingFangSC,PingFangSC-Medium;
    font-weight: 500;
    text-align: center;
    line-height: 18px;
    cursor: pointer;
    outline: 0;
    color:#333;
    background-color: #ffb300;
    &:hover{
    background-color: #e4a30d !important;
    }
  }

}

.text{
  font-size: 12px;
  color:#887e7e;
}
</style>
